// pages/nav/cms/nav_cms.js
const mybehavior = require("../../../../behaviors/requests")
Page({

  /**
   * 页面的初始数据
   */
  behaviors: [mybehavior],
  data: {
    select_style: "width: 136rpx;height: 48rpx;background: #5555FF;border-radius: 24rpx 24rpx 24rpx 24rpx;opacity: 1;position: absolute;top: 108rpx;left: 28rpx;",
    tag_style1: "position: absolute;top: 114rpx;left: 48rpx;width: 96rpx;height: 36rpx;font-size: 24rpx;font-weight: 600;color: #666666;line-height: 36rpx;color:white;",
    tag_style2: "position: absolute;top: 114rpx;left: 196rpx;width: 96rpx;height: 36rpx;font-size: 24rpx;font-weight: 600;color: #666666;line-height: 36rpx;",
    tag_style3: "position: absolute;top: 114rpx;left: 344rpx;width: 96rpx;height: 36rpx;font-size: 24rpx;font-weight: 600;color: #666666;line-height: 36rpx;",
    tag_style4: "position: absolute;top: 114rpx;left: 492rpx;width: 120rpx;height: 36rpx;font-size: 24rpx;font-weight: 600;color: #666666;line-height: 36rpx;",
    show11: true,
    show22: false,
    show33: false,
    show44: false,
    show55: false,
    show_gzcgl: false,
    show_lcia: false,
    first_word: "业务处理",
    selfMade_count: 0,
    scrapDeal_count: 0,
    handling_count: 0,
    advise_count: 0,
    baseUrl: "https://logisticsengineering.gree.com/container_manage_api/container_manage",

  },


  routeJump(e) {
    this.checkAuth(e)

  },
  // 标签切换
  tagChange1() {

    this.setData({
      show_gzcgl: false,
      show_lcia: false,
      show11: true,
      first_word: "业务处理",
      show22: false,
      show33: false,
      show44: false,
      tag_style1: "position: absolute;top: 114rpx;left: 48rpx;width: 96rpx;height: 36rpx;font-size: 24rpx;font-weight: 600;color: #666666;line-height: 36rpx;color:white;",
      tag_style2: "position: absolute;top: 114rpx;left: 196rpx;width: 96rpx;height: 36rpx;font-size: 24rpx;font-weight: 600;color: #666666;line-height: 36rpx;",
      tag_style3: "position: absolute;top: 114rpx;left: 344rpx;width: 96rpx;height: 36rpx;font-size: 24rpx;font-weight: 600;color: #666666;line-height: 36rpx;",
      tag_style4: "position: absolute;top: 114rpx;left: 492rpx;width: 96rpx;height: 36rpx;font-size: 24rpx;font-weight: 600;color: #666666;line-height: 36rpx;",
      tag_style3: "position: absolute;top: 114rpx;left: 344rpx;width: 96rpx;height: 36rpx;font-size: 24rpx;font-weight: 600;color: #666666;line-height: 36rpx;",
      tag_style4: "position: absolute;top: 114rpx;left: 492rpx;width: 120rpx;height: 36rpx;font-size: 24rpx;font-weight: 600;color: #666666;line-height: 36rpx;",
      select_style: "width: 136rpx;height: 48rpx;background: #5555FF;border-radius: 24rpx 24rpx 24rpx 24rpx;opacity: 1;position: absolute;top: 108rpx;left: 28rpx;",
    })
  },
  tagChange2() {
    this.setData({
      show11: false,
      show22: true,
      show33: false,
      show_gzcgl: false,
      show_lcia: false,
      show44: false,
      tag_style1: "position: absolute;top: 114rpx;left: 48rpx;width: 96rpx;height: 36rpx;font-size: 24rpx;font-weight: 600;color: #666666;line-height: 36rpx;color: #666666;;",
      tag_style2: "position: absolute;top: 114rpx;left: 196rpx;width: 96rpx;height: 36rpx;font-size: 24rpx;font-weight: 600;color: #666666;line-height: 36rpx;color:white;",
      tag_style3: "position: absolute;top: 114rpx;left: 344rpx;width: 96rpx;height: 36rpx;font-size: 24rpx;font-weight: 600;color: #666666;line-height: 36rpx;",
      tag_style4: "position: absolute;top: 114rpx;left: 492rpx;width: 120rpx;height: 36rpx;font-size: 24rpx;font-weight: 600;color: #666666;line-height: 36rpx;",
      select_style: "width: 136rpx;height: 48rpx;background: #5555FF;border-radius: 24rpx 24rpx 24rpx 24rpx;opacity: 1;position: absolute;top: 108rpx;left: 162rpx;",

    })
  },
  tagChange3() {
    this.setData({
      show11: false,
      show22: false,
      show_gzcgl: false,
      show_lcia: false,
      show33: true,
      show44: false,
      tag_style1: "position: absolute;top: 114rpx;left: 48rpx;width: 96rpx;height: 36rpx;font-size: 24rpx;font-weight: 600;color: #666666;line-height: 36rpx;",
      tag_style2: "position: absolute;top: 114rpx;left: 196rpx;width: 96rpx;height: 36rpx;font-size: 24rpx;font-weight: 600;color: #666666;line-height: 36rpx;",
      tag_style3: "position: absolute;top: 114rpx;left: 344rpx;width: 96rpx;height: 36rpx;font-size: 24rpx;font-weight: 600;color: #666666;line-height: 36rpx;color:white;",
      tag_style4: "position: absolute;top: 114rpx;left: 492rpx;width: 120rpx;height: 36rpx;font-size: 24rpx;font-weight: 600;color: #666666;line-height: 36rpx;",
      select_style: "width: 136rpx;height: 48rpx;background: #5555FF;border-radius: 24rpx 24rpx 24rpx 24rpx;opacity: 1;position: absolute;top: 108rpx;left: 310rpx;",
    })
  },
  tagChange4() {
    this.setData({
      show11: false,
      show22: false,
      show_gzcgl: false,
      show_lcia: false,
      show33: false,
      show44: true,
      tag_style1: "position: absolute;top: 114rpx;left: 48rpx;width: 96rpx;height: 36rpx;font-size: 24rpx;font-weight: 600;color: #666666;line-height: 36rpx;",
      tag_style2: "position: absolute;top: 114rpx;left: 196rpx;width: 96rpx;height: 36rpx;font-size: 24rpx;font-weight: 600;color: #666666;line-height: 36rpx;",
      tag_style3: "position: absolute;top: 114rpx;left: 344rpx;width: 96rpx;height: 36rpx;font-size: 24rpx;font-weight: 600;color: #666666;line-height: 36rpx;",
      tag_style4: "position: absolute;top: 114rpx;left: 492rpx;width: 120rpx;height: 36rpx;font-size: 24rpx;font-weight: 600;color: #666666;line-height: 36rpx;color:white;",
      select_style: "width: 136rpx;height: 48rpx;background: #5555FF;border-radius: 24rpx 24rpx 24rpx 24rpx;opacity: 1;position: absolute;top: 108rpx;left: 458rpx;",
    })
  },
  // 工装车管理展示
  showGZCGL() {
    this.setData({
      first_word: "返回上级",
      show_gzcgl: true,
      show11: false,
    })
  },
  // LCIA管理展示
  routeJumpLcia() {
    this.setData({
      first_word: "返回上级",
      show_lcia: true,
      show11: false,
    })
  },
  // 获取数据
  getHandlingCount() {
    let self = this;
    let url = self.data.baseUrl + "/get_current_task"
    let data = {
      page_size: 9999,
      page: 1,
    }
    this.post(url, data).then(res => {
        console.log("工装容器工装容器工装容器工装容器",res);
        if (res.code == 20000) {
        console.log("工装容器工装容器工装容器工装容器",res);

        self.setData({
          handling_count: res.data.total



        })


      } else {

      }
    }).catch(err => {
      self.setData({
        handling_count: 0



      })


    })
  },

  // 获取数据
  getAdviseCount() {
    let self = this;
    let url = "https://logisticsengineering.gree.com/pfep2_api/personal_task_manage/query_current_total_task"
    let data = {
      page_size: 9999,
      page: 1,
      database: "containers",
      query_cond: {
        table_name: { $regex: "service_all" }
      },
    }
    this.post(url, data).then(res => {
      if (res.code == 20000) {

        self.setData({
          advise_count: res.data.total



        })


      } else {

      }
    }).catch(err => {
      self.setData({
        advise_count: 0



      })


    })
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {

  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {
    const that = this
    that.getHandlingCount()
    that.getAdviseCount()
    this.post('https://logisticsengineering.gree.com/container_manage_api/diy_frock_manage/query_frock_list',).then((res) => {
      console.log(res)
      that.setData({
        selfMade_count: res.data.length
      })
    }).catch((err) => {
      console.log("error", err);
      if (err.data.code != 20000) {
        console.log(err.msg);
        // wx.showToast({
        //   title: err.msg,
        // })
      }
    })
    this.post('https://logisticsengineering.gree.com/container_manage_api/scrap_frock_manage/query_scrap_list',).then((res) => {
      console.log(res)
      that.setData({
        scrapDeal_count: res.data.length
      })
    }).catch((err) => {
      console.log("error", err);
      if (err.data.code != 20000) {
        console.log(err.msg);
        // wx.showToast({
        //   title: err.msg,
        // })
      }
    })

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {

  },

})